<?php

namespace app\common\model;

use think\Model;

class GoodsModel extends Model
{
    public $autoWriteTimestamp = true;

    public static function getClass($id = '')
    {
        $lst = [0 => '全部', 1 => '一毛专区', 2 => '新品专区', 3 => '性价比专区'];
        return $id ? $lst[$id] : $lst;
    }

    public static function getStorage($id = '')
    {
        $lst = [0 => '全部仓储', 1 => '义乌仓储', 2 => '广州（中通）仓', 3 => '河南南阳仓', 4 => '驻马店上蔡仓', 5 => '洛阳龙门仓储'];
        return $id ? $lst[$id] : $lst;
    }

    public static function newgoods()
    {
        return self::where('goods_status', 1)->where('isdel', 0)
            ->order('create_time', 'desc')
            ->limit(10)->select()
            ->each(function ($v, $k) {
                $v['image'] = cmf_get_image_url($v['image']);
            });
    }

    public static function topgoods()
    {
        return self::where('goods_status', 1)->where('is_top', 1)
            ->where('isdel', 0)
            ->order('create_time', 'desc')
            ->limit(10)->select()
            ->each(function ($v, $k) {
                $v['image'] = cmf_get_image_url($v['image']);
            });
    }
}
